home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / config / i386-emul / preparecontext.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  2KB  |  91 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: preparecontext.c,v 1.4 1996/10/24 15:51:12 aros Exp $
  4.     $Log: preparecontext.c,v $
  5.     Revision 1.4  1996/10/24 15:51:12  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.3  1996/08/13 14:04:57  digulla
  9.     Replaced AROS_LA by AROS_LHA
  10.  
  11.     Revision 1.2  1996/08/01 17:41:26  digulla
  12.     Added standard header for all files
  13.  
  14.     Desc:
  15.     Lang:
  16. */
  17. #include <exec/types.h>
  18. #include <aros/libcall.h>
  19.  
  20. /*****************************************************************************
  21.  
  22.     NAME */
  23.  
  24.     AROS_LH3I(APTR, PrepareContext,
  25.  
  26. /*  SYNOPSIS */
  27.     AROS_LHA(APTR, stackPointer, A0),
  28.     AROS_LHA(APTR, entryPoint,   A1),
  29.     AROS_LHA(APTR, fallBack,     A2),
  30.  
  31. /*  LOCATION */
  32.     struct ExecBase *, SysBase, 9, Exec)
  33.  
  34. /*  FUNCTION
  35.     Allocates the space required to hold a new set of registers on the
  36.     Stack given by stackPointer and clears the area except for pc which
  37.     is set to the address given by entryPoint.
  38.  
  39.     INPUTS
  40.     stackPointer - Pointer to a scpecific stack
  41.     entryPoint   - Address of the function to call when the new context
  42.                becomes active.
  43.     fallBack     - Address to be called when the entryPoint function ended
  44.                with an rts.
  45.  
  46.     RESULT
  47.     The new Stackpointer with the underlying context.
  48.  
  49.     NOTES
  50.     This function is for internal use by exec only.
  51.  
  52.     This function is processor dependant.
  53.  
  54.     EXAMPLE
  55.  
  56.     BUGS
  57.  
  58.     SEE ALSO
  59.     SwitchTasks()
  60.  
  61.     INTERNALS
  62.  
  63.     HISTORY
  64.  
  65. ******************************************************************************/
  66. {
  67.     AROS_LIBFUNC_INIT
  68.     UBYTE *sp=(UBYTE *)stackPointer;
  69.     int i;
  70.  
  71.     /* i386 version. No FPU supported yet. */
  72.  
  73.     /* Push fallback address */
  74.     sp-=sizeof(APTR);
  75.     *(APTR *)sp=fallBack;
  76.  
  77.     /* Now push the context. Prepare returnaddress (pc). */
  78.     sp-=sizeof(APTR);
  79.     *(APTR *)sp=entryPoint;
  80.  
  81.     /* Push 7 registers */
  82.     for(i=0;i<7;i++)
  83.     {
  84.     sp-=sizeof(LONG);
  85.     *(LONG *)sp=0;
  86.     }
  87.  
  88.     return sp;
  89.     AROS_LIBFUNC_EXIT
  90. } /* PrepareContext */
  91.